package com.ericsson.middleware.ContextBroker;

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;



@Path("/jsonServices")
public class SubscribeResponseRestService {
	
	private final static Logger LOGGER = Logger.getLogger(SubscribeResponseRestService.class
			.getName());

	@POST
	@Path("/subscribeResponse")
	@Consumes(MediaType.APPLICATION_JSON)
	public Response consumeJSON( String json ) {

		
		LOGGER.log(Level.INFO, "RECV SUBSCRIBE RESPONSE: " + json);
//		UpdateContextResponse updateLamps = (UpdateContextResponse) JsonUtil.fromJson(json, UpdateContextResponse.class);
//		
//		// Check valid updateLamps
//		if (updateLamps == null) {
//			 Response.status(500).entity("Null updateLamps detected.").build();
//		}
 		
// 		System.out.println("Received:" + json);
		
		// Check valid updateLamps type
//		if (updateLamps.getContextResponses()==null) return Response.status(500).build();
			      
        // Update lamps
	//	updateLamps(updateLamps);

        // Returns accepted       
		return Response.status(200).entity(json).build();
	}

	/**
	 * Update lamps status when needed
	 * @param event
	 */
	@SuppressWarnings("unused")
	private void updateLamps(UpdateContextResponse event) {
		//do something
	}

}
